parser grammar ExpresionesParser;

options {
  language = Java;
  tokenVocab = ExpresionesLexer;
  backtrack = true;
  ASTLabelType = MyTree;
  output=AST;
}

tokens {
   LISTA_INST;
}

@header {
  package practica12;
}

@members {

//    List<CommonTree> lista = new ArrayList<CommonTree>();
//    Hashtable variables = new Hashtable();
    
    private ArrayList<RecognitionException> errors = new ArrayList<RecognitionException>();
    public ArrayList<RecognitionException> getErrors() {
       return errors;
    }
    @Override
    public void reportError (RecognitionException e) {
       String msg = getErrorMessage(e, getTokenNames());
       System.err.println(msg);
       errors.add(e);
    }
}

instrucciones: (expresion PUNTO_COMA)* -> ^(LISTA_INST (expresion)*);

//asignacion: IDENT ASIGNA^ comparacion;

//comparacion: expresion (COMPARADORES^ expresion)?;

expresion: exp_mult ((MAS^|MENOS^) exp_mult)*;

exp_mult : exp_base ((MULT^|DIV^) exp_base)* ;

exp_base : (MENOS^)? (NUMERO | IDENT | PARENTESIS_A! expresion PARENTESIS_C!);



